<%@ page language="java" 
	contentType="text/html; 
	charset=UTF-8"
	pageEncoding="UTF-8"
	import="connectMysql.TestConnect"
	%>
	
	
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>检查</title>
</head>
<body>
<%
	String user_id=request.getParameter("id");
	String code=request.getParameter("code");
	String redirectPage="main.jsp?id="+user_id;
	String class_name=connectMysql.TestConnect.code_to_class_name(code);
	
	boolean member_exist=connectMysql.TestConnect.check_member_exist(user_id, code);
	String message="添加失败！";
	if(class_name==null){
		message="邀请码错误，请重新输入！";}
	else{
		if(member_exist){
			message="已加入班级，请勿重复进入！";
		}
		else if(connectMysql.TestConnect.insert_class(user_id, class_name)){
			message="添加成功！";}}
%>
<script>
    alert("<%= message%>");
    window.location.href = "<%= redirectPage %>";
</script>


</body>
</html>